import {uniqueId} from 'lodash'

/**
 * @description 给菜单数据补充上 path 字段
 * @description https://github.com/d2-projects/d2-admin/issues/209
 * @param {Array} menu 原始的菜单数据
 */
function supplementPath(menu) {
  return menu.map(e => ({
    ...e,
    path: e.path || uniqueId('d2-menu-empty-'),
    ...e.children ? {
      children: supplementPath(e.children)
    } : {}
  }))
}

export const menuHeader = supplementPath([])

export const menuAside = supplementPath([
  {path: '/index', title: '首页', icon: 'home'},
  {
    title: '用户管理',
    icon: 'users',
    children: [
      {path: '/user', title: '用户浏览'},
      {path: '/user/create', title: '用户新增'},
      {path: '/trace', title: '追溯'}
    ]
  },
  {
    title: '订单管理',
    icon: 'file-text',
    children: [
      {path: '/batch', title: '订单浏览'},
      {path: '/batch/create', title: '订单新增'}
    ]
  },
  {
    title: '产品管理',
    icon: 'delicious',
    children: [
      {path: '/product', title: '产品浏览'},
      {path: '/product/category', title: '产品类别浏览'},
      {path: '/product/categoryCreate', title: '产品类别新增'}
    ]
  },
  {
    title: '包装盒管理',
    icon: 'dropbox',
    children: [
      {path: '/packet', title: '包装盒浏览'},
      {path: '/packet/create', title: '包装盒新增'},
      {path: '/packet/category', title: '包装盒类别浏览'},
      {path: '/packet/categoryCreate', title: '包装盒类别新增'}
    ]
  },
  {
    title: '供应商管理',
    icon: 'user-secret',
    children: [
      {path: '/supplier', title: '供应商浏览'},
      {path: '/supplier/create', title: '供应商新增'}
    ]
  },
  {
    title: '原料管理',
    icon: 'joomla',
    children: [
      {path: '/material', title: '原料浏览'},
      {path: '/material/create', title: '原料新增'},
      {path: '/material/category', title: '原料类别浏览'},
      {path: '/material/categoryCreate', title: '原料类别新增'}
    ]
  }
])
